package com.paas.form.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper;
import com.bpm.feign.model.ProcessCmd;
import com.paas.common.model.RestResponse;
import com.paas.common.model.ResultMessage;
import com.paas.common.util.BeanUtil;
import com.paas.common.util.StringUtil;
import com.paas.form.constant.FormConstant;
import com.paas.form.dto.FormViewPubChangeDto;
import com.paas.form.entity.FormAttributePubEntity;
import com.paas.form.entity.FormViewChangeInfoDetailEntity;
import com.paas.form.entity.FormViewPubEntity;
import com.paas.form.service.IFormAttributePubService;
import org.apache.commons.lang.reflect.FieldUtils;
import org.springframework.stereotype.Service;

import com.paas.form.dao.FormViewChangeInfoDao;
import com.paas.form.entity.FormViewChangeInfoEntity;
import com.paas.form.service.IFormViewChangeInfoService;
import com.paas.common.web.service.BaseServiceImpl;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

@Service("formViewChangeInfoService")
public class FormViewChangeInfoServiceImpl  extends BaseServiceImpl<FormViewChangeInfoDao,FormViewChangeInfoEntity> implements IFormViewChangeInfoService{


    /**
     * 判断是否存在变更
     * @param type 变更类型
     * @param linkId 业务id
     * @return
     */
    public boolean isExistsChange(String type, String linkId) {
        QueryWrapper<FormViewChangeInfoEntity> queryWrapper = new QueryWrapper<FormViewChangeInfoEntity>();
        queryWrapper.eq("type",type);
        queryWrapper.eq("link_id",linkId);
        queryWrapper.eq("operation_status", FormConstant.CHANGE_OPERATION_APPROVAL);
        Integer count = this.baseMapper.selectCount(queryWrapper);
        return count > 0;
    }

    /**
     * 判断是否存在变更
     * @param type
     * @param linkId
     * @param changeId
     * @return
     */
    public boolean isExistsChange(String type, String linkId,String changeId) {
        QueryWrapper<FormViewChangeInfoEntity> queryWrapper = new QueryWrapper<FormViewChangeInfoEntity>();
        queryWrapper.eq("type",type);
        queryWrapper.eq("link_id",linkId);
        queryWrapper.eq("operation_status",FormConstant.CHANGE_OPERATION_APPROVAL);
        queryWrapper.ne("id", changeId);
        Integer count = this.baseMapper.selectCount(queryWrapper);
        return count > 0;
    }
	
}